<template>
  <div class="modal" :class="classNames" :style="Style">
    <slot></slot>
  </div>
</template>

<script>
export default {
  name: 'modal',
  props: {
    value: {
      type: Boolean,
      required: true
    },
    zIndex: {
      type: Number,
      default: 1000
    }
  },
  methods: {
    open () {
      this.$emit('input', true)
    },
    close () {
      this.$emit('input', false)
      this.$emit('close')
    },
    handleMask () {
      this.$emit('click')
    }
  },
  computed: {
    name () {
      return ['fade', 'slide'].includes(this.type) ? this.type : 'slide'
    },
    classNames () {
      return {
        show: this.value
      }
    },
    Style () {
      return {
        zIndex: this.zIndex
      }
    }
  }
}
</script>

<style scoped>
  .modal {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,.4);
    opacity: 0;
    transition: opacity .3s;
    pointer-events: none;
  }
  .modal.show {
    opacity: 1;
    pointer-events: auto;
  }

</style>
